package 插入;

public class 插入排序 {
    public static void insert_sorrt(int a[]) {
        int temp;
        for (int i=0;i<a.length;i++)
        {
            for (int j=i;j>0;j--){
                if (a[j]<a[j-1]){
                    temp=a[j];
                    a[j]=a[j-1];
                a[j-1]=temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        int a[] = new int[]{12, 13, 11, 14, 17, 15, 16, 21, 3};
        insert_sorrt(a);
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + ",");
        }

    }

}
